home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir38 / getpixel.zip / GETPIXEL.TBK (.txt)
Asymetrix ToolBook File  |  1993-05-05  |  64KB  |  498 lines

  1. Arial
  2. enterBook
  3. enterBook
  4. sizeToPage
  5. System
  6. y`D|D|
  7. Arial
  8. Arial
  9. Arial
  10. enterBook
  11. enterBook
  12. sizeToPage
  13. urier
  14. Arial
  15. Arial
  16. izeToPage
  17. Banner
  18. Get pixel in any window
  19. ToolBook
  20. This page allows you to get the color of a pixel clicked on anywhere on the screen.
  21. The page script for this page contains all of the handlers.  The enterPage handler links to USER, KERNEL, GDI, and TBKWIN for functions that will be used to determine which pixel was clicked on and what the RGB and HLS values are for that pixel.  
  22. When the page or background is clicked a buttonUp handler minimizes the ToolBook window, translates the left mouse button up message from windows and captures all mouse and keyboard input to ToolBook.  When ToolBook gets a WM_LBUTTONUP message from windows it sends the message to this page, which determines which pixel was clicked on and fills out the fields and sets the fillcolor of the rectangle.
  23. To use the demo, just click anywhere on the page to minimize ToolBook, then click on the pixel whose RGB and HLS value you want.  ToolBook will automatically restore itself and the value for the pixel will be displayed in the fields.
  24. The script is heavily commented so I will refer you there for a more detailed explanation.
  25. 0,255,05555
  26. color
  27. 120,50,1000100
  28. R G B
  29. H L S
  30. Title
  31. Chapter Name
  32. buttonUp
  33. buttonUp
  34. buttonUp
  35. buttonUp
  36. buttonUp
  37. Get pixel in ToolBook window
  38. ToolBook
  39. Clicking the left mouse button in the ToolBook window causes the RGB and HLS fields to be updated and the fillColor of the rectangle to be set to the color of the pixel that was clicked on.  Because ToolBook objects can only use the system colors, the rectangle may be dithered if you choose a pixel from the windsurfer graphic.
  40. The enterPage script for this page links the GDI function: GetPixel(), the TBKWIN DLL functions: RGBtoHLS() and ClientFromPage(), and the USER function GetDC().  
  41. The page handles the buttonUp message where it translates the page unit into screen units and calls GetPixel() with the point that was clicked on.  It then extracts the red, green, and blue values from the return value and sets the text of the fields.
  42. The background script sends the  buttonUp message back to the page because there are recordfields on the page. 
  43. To use the example click anywhere on the ToolBook page and watch the fields and rectangle change.    the ToolBook page and watch the fields and rectangle change.  . 
  44. 160,160,16435
  45. color
  46. 240,63.5,2.18758755
  47. :PHYSSIZE
  48. :PHYSSIZE
  49. 4hPointStruct, lpPointStruct
  50. --Standard stuff 
  51. BBS template
  52. " > 0
  53. --End Standare 
  54.     linkDLL USER
  55.         INT ClientToScreen(WORD,POINTER)
  56.  GetWindowDC(
  57. 5GetWindowRect(
  58. 7 GetParent(
  59. ]ReleaseCapture()
  60. rReleaseDC(
  61. s SetCapture(
  62. ScreenToClient(
  63. ShowWindow(
  64.  WindowFromPoint(DWORD)
  65.  GetMessagePos()
  66. ( GetPixel(
  67. KERNEL
  68. M GlobalAlloc(
  69.  GlobalLock(
  70. x GlobalUnlock(
  71.  GlobalFree(
  72. "TBKWIN.DLL"
  73.         STRING RGBtoHLS(
  74. --Allocate memory 
  75.  Structures
  76. 68, 12)
  77. --Hide the ToolBook 
  78. allow access 
  79. screen
  80. --Translate 
  81. Smouse 
  82. Bup messages that 
  83. Send 
  84. tuser defined 
  85. / WM_LBUTTONUP 
  86. gets 
  87.     translateWindowMessage 
  88. --Tell Windows 
  89. keyboard 
  90. setCapture(
  91.  was sent 
  92.  coords.
  93. --(I didn't 
  94. lParam because 
  95. relative 
  96. screenCoords 
  97.  takes 
  98. value 
  99. sturcture, 
  100. --The point structure 
  101. just a 
  102. loword
  103. hiword.
  104. This 
  105. same 
  106.  returns - how convinent. 
  107. --We want 
  108. topmost 
  109. so we walk 
  110. --out 
  111. nested child windows.
  112. hWnd 
  113. --Get 
  114. Device Context 
  115. whole 
  116. you can choose
  117. title bar 
  118. --User 
  119. function 
  120. convert 
  121.  coordinates given 
  122. Coordinates 
  123. upper 
  124. Scorner 
  125. clicked.
  126. screenToWindow(
  127. pixel 
  128. --If 
  129. clipping region 
  130. specified DC
  131. --Take appart 
  132. COLORREF 
  133. returned 
  134. 4294967295 -- 0xFFFFFFFF 
  135. redValue 
  136. k256 -- 
  137. lobyte 
  138. y256 -- 
  139. bits 8 
  140. greenValue 
  141. k256 -- 
  142. y256 -- 
  143. blueValue 
  144. HLSValue 
  145. = -20
  146. + conversion failed "
  147. "RGB" 
  148. &","&
  149. &","&
  150. "color" 
  151. --Clean up    
  152. , hDC)
  153.     untranslateWindowMessage 514 
  154. allocated 
  155. ScreenToWindow 
  156. xWinCoords 
  157. pointerINT(0, 
  158. yWinCoords 
  159. pointerDWORD(0, 
  160.     , 0)
  161. xClientCoords 
  162. yClientCoords 
  163. xOffset 
  164. yOffset 
  165. xCoord 
  166. yCoord 
  167. buttonUp
  168. enterPage
  169. WM_LBUTTONUP
  170. leavePage
  171. ScreenToWindow
  172. enterPage
  173. ClientToScreen
  174. GetWindowDC
  175. GetWindowRect
  176. GetParent
  177. ReleaseCapture
  178. ReleaseDC
  179. SetCapture
  180. ScreenToClient
  181. ShowWindow
  182. WindowFromPoint
  183. GetMessagePos
  184. GetPixel
  185. GlobalAlloc
  186. GlobalLock
  187. GlobalUnlock
  188. GlobalFree
  189. TBKWIN.DLL
  190. RGBtoHLS
  191. GlobalAlloc
  192. GlobalLock
  193. KERNEL
  194. hPointStruct
  195. lpPointStruct
  196. buttonUp
  197. ShowWindow
  198. WM_LBUTTONUP
  199. setCapture
  200. WM_LBUTTONUP
  201. GetMessagePos
  202. WindowFromPoint
  203. GetParent
  204. GetWindowDC
  205. screenToWindow
  206. GetPixel
  207. RGBtoHLS
  208. RGB to HLS conversion failed 
  209. color
  210. ReleaseDC
  211. ReleaseCapture
  212. ShowWindow
  213. HLSValue
  214. blueValue
  215. greenValue
  216. redValue
  217. screenCoords
  218. leavePage
  219. GlobalUnlock
  220. GlobalFree
  221. hPointStruct
  222. ScreenToWindow
  223. GetWindowRect
  224. ClientToScreen
  225. ScreenToClient
  226. yCoord
  227. xCoord
  228. yOffset
  229. xOffset
  230. yClientCoords
  231. xClientCoords
  232. yWinCoords
  233. xWinCoords
  234. lpPointStruct
  235. screenCoords
  236. --Standard stuff 
  237. BBS template
  238. " > 0
  239.     linkDLL USER
  240.         WORD GetDC(
  241.         INT ReleaseDC(
  242.         DWORD GetPixel(
  243. _"TBKWIN.
  244.         STRING RGBtoHLS(
  245. ClientFromPage(
  246. , sysMagnification, 
  247. xCoord 
  248. yCoord 
  249. sysClientHandle)
  250. <> -1
  251. redValue 
  252. k256 -- 
  253. the lobyte 
  254. y256 -- 
  255. bits 8 
  256. greenValue 
  257. k256 -- 
  258. y256 -- 
  259. blueValue 
  260. that's 
  261. 6value
  262. HLSValue 
  263. = -20
  264. "RGB 
  265. , conversion failed "
  266. &","&
  267. &","&
  268. "color" 
  269. , hDC)
  270. enterPage
  271. buttonUp
  272. enterPage
  273. GetDC
  274. ReleaseDC
  275. GetPixel
  276. TBKWIN.DLL
  277. RGBtoHLS
  278. ClientFromPage
  279. buttonUp
  280. ClientFromPage
  281. GetDC
  282. GetPixel
  283. RGBtoHLS
  284. RGB to HLS conversion failed 
  285. color
  286. ReleaseDC
  287. HLSValue
  288. blueValue
  289. greenValue
  290. redValue
  291. yCoord
  292. xCoord
  293. Banner
  294. Disclaimer
  295. The files from Asymetrix Corporation On-line services are made available for demonstration and experimentation purposes, but they are not official Asymetrix products.  As such, they are not subject to our usual high standards of documentation or product review.  Feedback is welcome.  Please send your questions or comments to the Asymetrix BBS sysop.  Asymetrix does not provide phone support for these examples.
  296. This book and example scripts are Copyright Asymetrix Corporation.  Asymetrix gives you permission to copy, revise and reuse the individual objects and scripts in this application in your own applications.  Include the notice "Portions of this application are the copyright of Asymetrix Corporation" in your product if they contain objects or scripts copied from this application.  You may not copy the entire book (or a substantial part of it) for redistribution as your own product.w
  297. On-line
  298. "Asymetrix Corporation On-Line services include:"&CRLF&
  299.             TAB&"
  300. ?BBS"&
  301. CompuServe"&
  302. %America Online"&
  303. >BIX"&
  304. buttonUp
  305. buttonUp
  306. Asymetrix Corporation On-Line services include:
  307. Asymetrix BBS
  308. CompuServe
  309. America Online
  310. "The Asymetrix Corporation BBS can be reached 
  311. ):"&CRLF&
  312.             TAB&"(206) 451-1173 
  313. 2400 baud communications"&
  314. 48290 
  315. 9600 
  316. faster"&
  317.             "Settings are:
  318. NO parity, 1 stop bit, 
  319. 8 data bits."
  320. buttonUp
  321. buttonUp
  322. The Asymetrix Corporation BBS can be reached at:
  323. (206) 451-1173 for 2400 baud communications
  324. (206) 451-8290 for 9600 or faster
  325. Settings are:  NO parity, 1 stop bit, and 8 data bits.
  326. :PHYSSIZE
  327. Book Title
  328. Get Pixel
  329. buttonUp
  330. buttonUp
  331. ttvltt
  332. lltvvt
  333. vvtlttvt
  334. tltlv
  335. llttl
  336. ltlvttl
  337. lvvtlt
  338. ccvllc
  339. lvltltv
  340. cldvtlltlt
  341. ttclvltv
  342. AVllctt
  343. lltll
  344. cltll
  345. llVcV
  346. ttlltl
  347. lcVcl
  348. vvVlVlj
  349. lvcll
  350. vlcVlVcVlV
  351. tlvlt
  352. VlVlcll
  353. @cdcl
  354. vlltlltcll
  355. lc:VV
  356. tVltVlcl
  357. llcctc
  358. lvlclv
  359. @@Vll
  360. tlclc
  361. clvllvltlt
  362. tvllvlt
  363. VlltVllv
  364. Vllclcttvv
  365. lctlt
  366. tclltvld
  367. YYXXY
  368. XmX2XXm
  369. YYXG2GdLGX
  370. mG3318K
  371. mm2LX
  372. Gm2L22XL22
  373. G2GL2LL2L"
  374. PXXIIY
  375. XGmmGm
  376. mmYGGHYXmm
  377. GGLmLL
  378. O2GXGX
  379. G2"XXG2G
  380. 2mGXGG
  381. mGwXmm
  382. 2LLGwGXXmm
  383. 8GGXX
  384. vdGIIYSY
  385. @@j@j
  386. mXww88
  387. LXwGG
  388. PPjP@m
  389. ww8mw88 
  390. GIHHIm
  391. jPjjPPj
  392. w88ww88 
  393.  "2Gm2
  394. 22P@jP@
  395. "L22"
  396. IIHIXd
  397. A@VP@VdldV
  398. 5ddjPLP@@:
  399. PddPV
  400. 83IIHHLd
  401. @lPOSSGG
  402.  3IIHHG
  403. mHIIHIX
  404. A22" 
  405. 8^^8^
  406. Y/3IIYm
  407. GSS2S
  408. mmYY2
  409. /GGHG5GH5
  410. wL" 8
  411. /IIHHm2
  412. GH5H5H
  413. mXXL88  
  414. IHI5GH/
  415. md"Add2m
  416. /GG/G
  417. GG/    G
  418.  >A@"8""
  419. ""Adw^
  420. mXm2mw  
  421. mA"Vlw8"
  422. G/G/GG/
  423. L@"@d
  424. P           
  425.  3G//HG/
  426. /G/G/
  427.     1/G2S
  428. GGYIHH/
  429. 8K1%/1
  430. YYGGYH
  431. HGIHHYYX
  432. mII/I
  433. 35GGH
  434. 13K311
  435. ^8  88
  436. wsK88"
  437. XX8"P
  438. wXGXX
  439. wwKX%11 
  440. w8w8 "P
  441. "88228
  442. GXX2Pmmww
  443.  88XX
  444. m5IHH
  445. wXXKwX88
  446. X8K811
  447. YYGYG2A^^
  448. 811KKssww
  449. mHIHH
  450. KKX883Kw
  451. 8"8 "8Kss
  452. YYXXm2d
  453. XYGX2
  454. GGXX     
  455. 2 88 
  456. mHIHI
  457. mG22P
  458. YHHYY
  459. YHHGY
  460. mHHY2
  461. mYHHG2G2G2
  462. mGHYXXGG2
  463. mH/GX
  464. H5XXKXXw
  465.                                                         
  466.                                                         
  467.                                                         
  468.                                                         
  469.                                                         
  470.                                                         
  471.                                                         
  472.                                                         
  473.                                                         
  474.                                                         
  475.                                                         
  476.                                                         
  477.                                                         
  478.                                                         
  479.                                                         
  480.                                                         
  481. ist boxes
  482. color
  483. Get pixel in ToolBook window
  484. ToolBook
  485. Clicking the left mouse button in the ToolBook window causes the RGB and HLS fields to be updated and the fillColor of the rectangle to be set to the color of the pixel that was clicked on.  Because ToolBook objects can only use the system colors, the rectangle may be dithered if you choose a pixel from the windsurfer graphic.
  486. The enterPage script for this page links the GDI function: GetPixel(), the TBKWIN DLL functions: RGBtoHLS() and ClientFromPage(), and the USER function GetDC().  
  487. The page handles the buttonUp message where it translates the page unit into screen units and calls GetPixel() with the point that was clicked on.  It then extracts the red, green, and blue values from the return value and sets the text of the fields.
  488. The background script sends the  buttonUp message back to the page because there are recordfields on the page.  Messages passing up the heirarchy go to the parent of the object next and the parent of a recordField is the background. 
  489. To use the example click anywhere on the ToolBook page and watch the fields and rectangle change. 
  490. 0,100,0375,35.68755
  491. 240,63.5,2.18758755
  492. :PHYSSIZE
  493. :PHYSSIZE
  494. 255,255,255
  495. 120,50,1000100
  496. R G B
  497. H L S
  498.